package com.zhenwei.zscm.controller;

import com.zhenwei.zscm.common.annotations.MethodName;
import com.zhenwei.zscm.common.base.RestResult;
import com.zhenwei.zscm.model.vo.log.QueryExLogVO;
import com.zhenwei.zscm.model.vo.log.QueryLogVO;
import com.zhenwei.zscm.service.LogService;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/log")
@MethodName("日志管理")
@AllArgsConstructor
public class LogController {
    private LogService logService;

    @GetMapping("/login")
    @MethodName("查询登录日志")
    public RestResult getLoginLog(@RequestParam @NotNull(message = "分页索引不能为空") Integer pageNo, @RequestParam @NotNull(message = "分页大小不能为空") Integer pageSize) {
        return logService.getUserLoginLogs(pageNo, pageSize);
    }

    @PostMapping("/exception")
    @MethodName("查询系统异常日志")
    public RestResult getExceptionLog(@RequestBody @Valid QueryExLogVO query) {
        return logService.getExceptionLogs(query);
    }

    @PostMapping("")
    @MethodName("查询系统日志")
    public RestResult getLog(@RequestBody @Valid QueryLogVO query) {
        return logService.list(query);
    }
    @GetMapping("/exception/logTypes")
    @MethodName("获取异常日志类别")
    public RestResult getExLogTypes(){
        return logService.getExLogTypes();
    }
    @GetMapping("/types")
    @MethodName("获取日志类别")
    public RestResult getTypes(){
        return logService.getLogTypes();
    }

}
